(function(){
	window.Respack=arguments.callee;
	var Me=Respack;
	Me.files=[];
	Me.resItems=[];
	Me.start=function(){
		if(Shell.fs.existsSync(Shell.path+"res/@.js")){
			Me.finish();
			return;
		}
		var qs=["res/"];
		while(qs.length>0){
			var q=qs.shift();
			var arr=Shell.fs.readdirSync(Shell.path+q);
			for(var i=0;i<arr.length;i++){
				var file=arr[i];
				var filePath=Shell.path+q+file;
				var stat=Shell.fs.statSync(filePath);
				if(stat.isDirectory()){
					qs.push(q+file+"/");
					continue;
				}
				var ext=file.slice(-3);
				if(ext!="png"&&ext!="jpg") continue;
				var img=new Image();
				img.name=q+file;
				img.fileSize=stat.size;
				Me.files.push(img);
			}
		}
		Me.addResItem();
	}
	Me.addResItem=function(){
		if(Me.files.length==0){
			Me.setResItem();
			return;
		}
		var img=Me.files[0];
		img.src=Shell.path+img.name;
		img.onload=Me.addResItem2;
	}
	Me.addResItem2=function(){
		var img=Me.files[0];
		var symbol=img.name.slice(4,-4).replace(/\//g,".");
		var ext=img.name.slice(-3);
		var str=symbol+","+img.fileSize+(ext=="png"?"":"/"+ext)+","+img.width+","+img.height;
		Me.resItems.push(str);
		Me.files.shift();
		Me.addResItem();
	}
	Me.setResItem=function(){
		var code="window.t=[\n";
		for(var i=0;i<Me.resItems.length;i++){
			code+="\""+Me.resItems[i]+"\",\n";
		}
		code+="];";
		Shell.fs.writeFileSync(Shell.path+"res/@.js",code);
		Me.finish();
	}
	Me.finish=function(){
		G.start();
	}
})();